<!doctype html>
<html>
<head>
	<meta charset="UTF-8" />
	<meta name="robots" content="noindex,nofollow" />
	<title>管理后台</title>
	<link rel="stylesheet" href="__PUBLIC__/css/bootstrap-3.3.5/css/bootstrap.min.css" />
	<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
	<style>
	#warp{width:300px;margin:0 auto;margin-top:150px;}
	.error,#ajaxErrmsg{color:#f00}
	#loginForm{margin-top:10px;}
	</style>
</head>
<body>

<div id="warp">
	<h1 style="text-align:center;">管理后台</h1>
	<form id="loginForm" class="form-horizontal">
		<div class="form-group">
			<label for="username" class="usernameLebel col-sm-3 control-label">用户名</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" name="username" id="username" placeholder="用户名">
			</div>
		</div>
		<div class="form-group">
			<label for="password" class="passwordLabel col-sm-3 control-label">密码</label>
			<div class="col-sm-9">
				<input type="password" class="form-control" name="password" id="password" placeholder="密码">
			</div>
		</div>
		<div class="form-group">
			<label for="secode" class="secodeLabel col-sm-3 control-label">验证码</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" name="secode" id="secode" placeholder="验证码">
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-10" >
				<img src="<{:U('Admin/Login/verify')}>" style="margin-left:10px" alt="验证码" title="看不清？点击刷新验证码." onclick="this.src='<{:U('Admin/Login/verify')}>?'+Math.random()"/>
			</div>
		</div>
		
		<button type="submit" class="btn btn-info col-xs-12" >登录</button>
	</form>
</div>

<script src="__PUBLIC__/js/jquery-1.11.3.min.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script src="__PUBLIC__/js/validate/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/validate/messages_zh.js"></script>
<script>
$(function(){
	
	$("#loginForm").validate({
        rules: {
        	username: {
                required: true,
            },
            password: {
                required: true,
            },
            secode: {
                required: true,
            },
        },
        messages: {
        	username: {
                required: "请输入用户名！",
            },
            password: {
                required: "请输入密码！",
            },
            secode: {
                required: "请输入验证码！",
            },
        },
        submitHandler: function(form) {
        	var url = "<{:U('Admin/Login/checkin')}>";
        	$.post(url,$(form).serialize(),function(r){
    			if (r.error == 1){
    				layer.msg(r.errmsg);
    				return false;
    			}else{
    				window.location.href = "<{:U('Admin/Index/index')}>";
    			}
    		});
        	return false
 		}
        
    });
	
});
</script>
</body>
</html> 